Ans: It is a portable operating system that is designed for both efficient multi-tasking and multi-user functions. Its portability allows it to run on different hardware platforms. It was written in C and lets the user do processing and control under a shell.
Ans: A shell acts as an interface between the user and the system. As a command interpreter, the shell takes commands and sets them up for execution.
Ans: When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it.
for example, the parent may need to check the child’s exit status. To be able to get this information, the parent calls ‘wait()’;
In the interval between the child terminating and the parent calling ‘wait()’, the child is said to be a ‘zombie’ (If you do ‘ps’, the child will have a ‘Z’ in its status field to indicate this.)
Ans: Nohup is a special command which is used to run the process in the background, but it is slightly different than & which is normally used for putting a process in the background. A UNIX process started with nohup will not stop even if the user who has stared log off from the system. While the background process started with & will stop as soon as the user log off.
Ans:
Interested in mastering Unix Shell Scripting Training? Enroll now for FREE demo on "Unix Shell Scripting Training"
Ans: Signals are software interrupts. Signal provides a way of handling asynchronous events: a user at a terminal typing the interrupt key to stop a program or the next program in the pipeline terminating prematurely.
Ans: A Session is a collection of one or more process groups. A process establishes a new session by calling setsid function. This function return process groupid ok.
Ans: The ps command prints the process status for some or all of the running processes. The information given are the process identification number (PID),the amount of time that the process has taken to execute so far, etc.
Ans: All devices are represented by files called special files that are located in/dev directory. Thus, device files and other files are named and accessed in the same way. A ‘regular file’ is just an ordinary data file in the disk.
Ans: In a shell script we can use two types of variables :
System-defined variables are defined or created by Operating System(Linux) itself. These variables are generally defined in Capital Letters and can be viewed by “set” command.
Ans: First argument: $1,
Second argument :
$2 Example :
Script will copy file (arg1) to destination (arg2) ./copy.sh file1.txt /tmp/ cat copy.sh #!/bin/bash cp $1 $2
Ans: if [ -f /var/log/messages ]
then echo “File exists”
Ans: That line tells which shell to use. #!/bin/bash script to execute using /bin/bash. In the case of python script, there will be #!/usr/bin/python.
Ans: #
What would be the output of command: `{` -Z “” `}` && ECHO 0 || ECHO 1?
Ans:
Ans:
Ans: Add “exec >log.txt 2>&1” as the first command in the script.
Ans: echo ${variable#*:*:*:} or
echo ${variable##*:}
Ans: awk -F: ‘$3<100’ /etc/passwd
Ans: IFS=”:”
Ans: echo $* or echo $@
Ans: array=(“Hi” “my” “name” “is”)
Ans: Arguments can be passed as: script name “Arg1” “Arg2”….”Argn” and can be accessed inside the script as $1 , $2 .. $n.
Ans: cat file1 file2 file3 > file
Ans:
ls -l | grep '^-'|
awk 'BEGIN {sum=0}
{sum = sum + $5}
END
{print sum}'
Ans:
grep -w july filename The '-w' option makes the grep command to search for exact whole words. If the specified pattern is found in a string, then it is not considered as a whole word.
For example: In the string "mikejulymak", the pattern "july" is found. However "july" is not a whole word in that string.
Ans: sed 'p' < filename
Ans: wc -l /usr/ch* Another way is find /usr -name 'ch*' -type f -exec wc -l {} ;
Ans: The basename utility deletes any prefix ending in /. The usage is mentioned below: basename /usr/local/bin/file This will display the only file.
You liked the article?
Like: 1
Vote for difficulty
Current difficulty (Avg): Medium
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.